package pl.mindstorms.mywords;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MyWordsActivity extends Activity {

	private DBHelper db;
	private Button btCreate;
	private Button btAdd;
	
	private EditText edEnglish;
	private EditText edPolish;
	private TextView tv;
	private Context context;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        context = getApplicationContext();
        
        btCreate = (Button) findViewById(R.id.button1);
        btAdd = (Button) findViewById(R.id.button2);
        edEnglish = (EditText) findViewById(R.id.editEnglish);
        edPolish = (EditText) findViewById(R.id.editPolish);
        tv = (TextView) findViewById(R.id.textView2);
        
        db = new DBHelper(context);
        
        btCreate.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View arg0) {
				int a = db.getCount();
				tv.setText("Rekordow:" + a);
				//btCreate.setText(a);
				
			}
        	
        });
        
        btAdd.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				db.addWord(edEnglish.getText().toString(), edPolish.getText().toString());								
			}        	
        });
        
        
        
        
    }
}